Kenneth Tay
Oct 18, 2018
Reminder: Project proposals are due tomorrow night!
Reproducible research: publishing data analyses together with their data and code so that others may “reproduce” the findings.
Why reproducible research?
.R
file extensionsRStudio: R markdown is a document format which allows you to “weave together narrative text and code to produce elegantly formatted output.”
Made possible by the knitr
package (Yihui Xie)
knitr
package.Rmd
extensionsSurprise: (Almost) all the class material (including slides) was created with R markdown!
Markdown is a simple way to convert a text document into a web file (i.e. HTML) with basic styling.
Has support for:
Markdown reference here.
To see how your Markdown (.md) document looks like in real-time, use an online Markdown editor (e.g. dillinger.io)
Optional material
.Rmd
file in RStudio..html
file in the same folder as the .Rmd
file..html
file.
.Rmd
file in RStudio. As you are typing code in the .Rmd
file, enter this code into the RStudio console to see if it works.
.Rmd
file until it does..Rmd
file. Use rm(list = ls())
to empty your environment, run the code in your .Rmd
file sequentially in the RStudio console to see what went wrong.include = FALSE
: prevents code and results from appearing in the finished file. R Markdown still runs the code in the chunk, and the results can be used by other chunks.
echo = FALSE
: prevents code, but not the results from appearing in the finished file.
eval = FALSE
: Code appears in the output but is not run.
message = FALSE
: prevents messages that are generated by code from appearing in the finished file.
warning = FALSE
: prevents warnings that are generated by code from appearing in the finished.